//初始化数据
const state = {
    tabOptions: [],//tab标签的store
    activeIndex: '',
};
//action 异步的操作
const actions = {};
const mutations = {
    //tab列表
    // 添加tabs
    addTabs(state, data) {
        state.tabOptions.push(data);
    },
    // 删除tabs
    deleteTabs(state, route) {
        let index = 0;
        for (let option of state.tabOptions) {
            if (option.route === route) {
                break;
            }
            index++;
        }
        state.tabOptions.splice(index, 1);
    },
    // 设置当前激活的tab
    setActiveIndex(state, index) {
        state.activeIndex = index;
    },
    setTabOptions(state, data) {
        state.tabOptions = data;
    },
};
//getter 抛出去的数据
const getters = {
    //tab
    tabOptions: state => state.tabOptions,
    activeIndex: state => state.activeIndex,
};
export default {
    state,
    mutations,
    actions,
    getters,
};
